function [x, y, iter] = newtonIteration1(func, x0, x1, maxi, preEps)
%  输入：计算函数func 迭代初值x0,x1 最大迭代次数maxi 精度要求epsilon
%  返回：迭代结果，迭代次数
iter = 0; % 记录迭代次数
i = 0; % 步长缩小次数
lambda = 1;
y0 = func(x0);
y1 = func(x1);
if abs(y1) > abs(y0)
    temp = y0;
    y0 = y1;
    y1 = temp;
    temp = x0;
    x0 = x1;
    x1 = temp;
end
if abs(y1) < preEps || abs(abs(y0) - abs(y1)) <= preEps
    x = x1;
    y = y1;
else
    x2 = x1 - lambda*(y1/(y0-y1))*(x0-x1);
    x2 = upperLowerLimit(x2, 0, 60*pi/180);
    y2 = func(x2);
    while i <= maxi && abs(y2) >= abs(y1)
        disp('|f(x)|不满足单调递减条件，缩小步长参数')
        lambda = lambda/2;
        x2 = x1 - lambda*(y1/(y0-y1))*(x0-x1);
        x2 = upperLowerLimit(x2, 0, 60*pi/180);
        y2 = func(x2);
        i = i + 1;
    end
    iter = iter + 1; 
    lambda = 1;
    while iter <= maxi
        x0 = x1; y0 = y1;
        x1 = x2; y1 = y2;
        x2 = x1 - lambda*(y1/(y0-y1))*(x0-x1);
        x2 = upperLowerLimit(x2, 0, 60*pi/180);
        y2 = func(x2);
        while i <= maxi && abs(y2) >= abs(y1)
            disp('|f(x)|不满足单调递减条件，缩小步长参数')
            lambda = lambda/2;
            x2 = x1 - lambda*(y1/(y0-y1))*(x0-x1);
            x2 = upperLowerLimit(x2, 0, 60*pi/180);
            y2 = func(x2);
            i = i + 1;
        end
        iter = iter + 1; 
        lambda = 1;
        if abs(y2) <= preEps
            disp('abs(y2) <= preEps')
            break;
        end
        if abs(abs(y2) - abs(y1)) <= preEps
            disp('abs(abs(y2) - abs(y1)) <= preEps')
            break;
        end
    end
    x = x2;
    y = y2;
end
end